

#include "ChaosVector4.hpp"
#include <math.h>



namespace Chaos
{

	ChsVector4::ChsVector4(const float& x,const float& y,const float& z,const float& w)
	{
		m_fX = x;
		m_fY = y;
		m_fZ = z;
		m_fW = w;
	}

	ChsVector4::ChsVector4()
	{
		ChsVector4(0.0f,0.0f,0.0f,0.0f);
	}

	ChsVector4::ChsVector4(const float *vec)
	{
		ChsVector4(vec[0],vec[1],vec[2],vec[3]);
	}


	ChsVector4::ChsVector4(const ChsVector4& vec)
	{
		ChsVector4(vec.m_fX,vec.m_fY,vec.m_fZ,vec.m_fZ);
	}

	ChsVector4&	ChsVector4::operator += (const ChsVector4& vec)
	{
		m_fX +=vec.m_fX;
		m_fY +=vec.m_fY;
		m_fZ +=vec.m_fZ;
		m_fW +=vec.m_fW;
		return *this;
	}
	ChsVector4&	ChsVector4::operator -= (const ChsVector4& vec)
	{
		m_fX -=vec.m_fX;
		m_fY -=vec.m_fY;
		m_fZ -=vec.m_fZ;
		m_fW -=vec.m_fW;
		return *this;
	}
	ChsVector4&	ChsVector4::operator *= (const ChsVector4& vec)
	{
		m_fX *=vec.m_fX;
		m_fY *=vec.m_fY;
		m_fZ *=vec.m_fZ;
		m_fW *=vec.m_fW;
		return *this;
	}

	ChsVector4&	ChsVector4::operator *= (const float& scale)
	{
		m_fX *=scale;
		m_fY *=scale;
		m_fZ *=scale;
		m_fW *=scale;
		return *this;
	}
	ChsVector4&	ChsVector4::operator /= (const float& scale)
	{
		m_fX /=scale;
		m_fY /=scale;
		m_fZ /=scale;
		m_fW /=scale;
		return *this;
	}

	ChsVector4	ChsVector4::operator + (const ChsVector4& vec1)const
	{
		ChsVector4 result;
		result.m_fX = m_fX + vec1.m_fX;
		result.m_fY = m_fY + vec1.m_fY;
		result.m_fZ = m_fZ + vec1.m_fZ;
		result.m_fW = m_fW + vec1.m_fW;
		return result;
	}
	
	ChsVector4	ChsVector4::operator - (const ChsVector4& vec1)const
	{
		ChsVector4 result;
		result.m_fX = m_fX - vec1.m_fX;
		result.m_fY = m_fY - vec1.m_fY;
		result.m_fZ = m_fZ - vec1.m_fZ;
		result.m_fW = m_fW - vec1.m_fW;
		return result;
	}

	ChsVector4	ChsVector4::operator * (const float& scale)const
	{
		ChsVector4 result;
		result.m_fX = m_fX * scale;
		result.m_fY = m_fY * scale;
		result.m_fZ = m_fZ * scale;
		result.m_fW = m_fW * scale;
		return result;
	}
	ChsVector4	ChsVector4::operator / (const float& scale)const
	{
		ChsVector4 result;
		result.m_fX = m_fX / scale;
		result.m_fY = m_fY / scale;
		result.m_fZ = m_fZ / scale;
		result.m_fW = m_fW / scale;
		return result;
	}


	ChsVector4&	ChsVector4::operator = (const ChsVector4 & vec)
	{
		m_fX = vec.m_fX;
		m_fY = vec.m_fY;
		m_fZ = vec.m_fZ;
		m_fW = vec.m_fW;
		return *this;
	}

	float ChsVector4::Length()const
	{
		return sqrtf(LengthSQ());
	}

	float ChsVector4::LengthSQ()const
	{
		return m_fX * m_fX + m_fY * m_fY + m_fZ * m_fZ + m_fW * m_fW;
	}


}

